class HttpException extends Error {
    errorCode: number
    code: number
    msg: any
    constructor(msg = '服务器异常', errorCode = 10000, code = 400) {
        super()
        this.errorCode = errorCode
        this.code = code
        this.msg = msg
    }
}

class ParameterException extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.code = 400
        this.msg = msg || '参数错误'
        this.errorCode = errorCode || 10000
    }
}

class Success extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.code = 201
        this.msg = msg === undefined ? 'ok' : msg
        this.errorCode = errorCode || 20000
    }
}

class NotFound extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '资源未找到'
        this.errorCode = errorCode || 10000
        this.code = 404
    }
}

class AuthFailed extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '授权失败'
        this.errorCode = errorCode || 10004
        this.code = 401
    }
}

class Forbbiden extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '禁止访问'
        this.errorCode = errorCode || 10006
        this.code = 403
    }
}

class Fail extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '操作失败'
        this.errorCode = errorCode || 10007
        this.code = 405
    }
}

class Forbbidend extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '禁止操作'
        this.errorCode = errorCode || 10008
        this.code = 406
    }
}

class Repeatedly extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '资源已存在'
        this.errorCode = errorCode || 10009
        this.code = 407
    }
}

class NotFoundItem extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '资源未找到'
        this.errorCode = errorCode || 10010
        this.code = 408
    }
}
class MaxFileSize extends HttpException {
    constructor(msg?: any, errorCode?: number) {
        super()
        this.msg = msg || '上传文件过大'
        this.errorCode = errorCode || 10020
        this.code = 409
    }
}

export {
    NotFoundItem,
    HttpException,
    ParameterException,
    Success,
    NotFound,
    AuthFailed,
    Forbbiden,
    Fail,
    Forbbidend,
    Repeatedly,
    MaxFileSize
}